package util;

import org.junit.Test;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class MxHasHMap {

    @Test
    public void delete() {
        HashMap<Integer, String> map = new HashMap<>();
        map.put(1, "one");
        map.put(2, "two");
        map.put(3, "three");
        System.out.println(map);
        Iterator<Map.Entry<Integer, String>> it = map.entrySet().iterator();
        while (it.hasNext()) {
            it.next();
            it.remove();//使用迭代器的remove()方法删除元素
        }
        System.out.println(map);
    }


    @Test
    public void mxNullKey() {
        Map map = new HashMap();
        map.put(null, new Object());
    }
}
